<?php
	/*
	* 产品
	*/
	class product{
		
		public $t;
		public $PageSize=10;
		
		
		/*景点列表*/
		function getProductsList(){
			global $db;
			$sql="select * from attractions order by Att_sort, Att_createtime desc";
			$total=$db->QueryCount($sql);
			$this->t=array('total'=>$total,'perpage'=>$this->PageSize,'style'=>'a2');
			$tmpPage=empty($_GET['PageNum']) ? 0 : intval($_GET['PageNum']);
			$tmpPageSize=$tmpPage==0 ? 0 : ($tmpPage-1)*$this->PageSize;
			$sql .= ' limit '.$tmpPageSize.','.$this->PageSize ;
			$rs = $db->GetAllSql($sql);
			return $rs;
		}
		
		/*门票列表*/
		function getTicketLIst($attid,$name='',$begDate='',$endDate=''){
			global $db;
			$where=' and 1=1';
			if($begDate){
				$where.=" and Tkt_starttime > $begDate";	
			}
			if($endDate){
				$where.=" and Tkt_endtime > $endDate ";
			}
			
			if($begDate=='' and $endDate==''){
				$where.=" and Tkt_endtime > ".strtotime(date('Y-m-d'));	
			}
			if($name){
				$where.=" and Tkt_name like '%".$name."%'";	
			}
			$sql="select * from ticket where Tkt_att_id=$attid ".$where." order by Tkt_sort,Tkt_id desc";
			$rs=$db->GetAllSql($sql);
			return $rs;
		}
		
		/*景点拥有门票数量*/
		function getTicketNum($attid,$name='',$begDate='',$endDate=''){
			global $db;
			$where=' and 1=1';
			if($begDate){
				$where.=" and Tkt_starttime > $begDate";	
			}
			if($endDate){
				$where.=" and Tkt_endtime > $endDate ";
			}
			
			if($begDate=='' and $endDate==''){
				$where.=" and Tkt_endtime > ".strtotime(date('Y-m-d'));	
			}
			if($name){
				$where.=" and Tkt_name like '%".$name."%'";	
			}
			$sql="select count(*) as num from ticket where Tkt_att_id=$attid".$where;
			$rs=$db->GetOneSql($sql);
			return $rs['num'];
		}
		
		/*门票详细*/
		function getTicketDetail($id){
			global $db;
			$sql="select * from ticket where Tkt_id=$id";
			$rs=$db->GetOneSql($sql);
			return $rs;
		}
		
		/*景点详细*/
		function getProductsDetail($id){
			global $db;
			$sql="select * from attractions where Att_id=$id";
			$rs=$db->GetOneSql($sql);
			return $rs;
		}
		/*帮助列表*/
		function getHelpList(){
			global $db;
			$keyword="";
			if(isset($_GET['keyword'])) {
			  $keyword = $_GET['keyword'];
			};
			$where = "";
			if($keyword){
			  $where=" and news_title like '%".$keyword."%'";	
			}
			$sql="select * from web_newslist where 1=1 ".$where." and newstype_id=2 and isdel=0 order by news_creattime desc,news_updatetime desc";
			$total=$db->QueryCount($sql);
			$this->t=array('total'=>$total,'perpage'=>$this->PageSize,'style'=>'a2');
			$tmpPage=isset($_GET['PageNum']) ? intval($_GET['PageNum']):0;
			$tmpPageSize=$tmpPage==0 ? 0 : ($tmpPage-1)*$this->PageSize;
			$sql .= ' limit '.$tmpPageSize.','.$this->PageSize ;
			$rs = $db->GetAllSql($sql);
			return $rs;
		}
		
		/*文章详细*/
		function getHelpDetail($id){
			global $db;
			$sql="select * from web_newslist where id=$id";
			$rs=$db->GetOneSql($sql);
			return $rs;
		}
		/*
		* 分页
		*/
		function page(){
			return new page($this->t);	
		}
		
		
		
	}
?>